<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>评价</title>
</head>
<script src="/js/global.js"></script>
<link rel="stylesheet" href="/css/font.css" type="text/css"/>
<link rel="stylesheet" href="/css/layui.css" type="text/css"/>
<link rel="stylesheet" href="/css/xadmin.css" type="text/css"/>
<script type="text/javascript" src="/js/layui.js"></script>
<script type="text/javascript" src="/js/xadmin.js"></script>
<link rel="stylesheet" href="/css/style.css" type="text/css"/>
<script type="text/javascript" src="/js/index.js"></script>
<script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
<body>

<div class="layui-form" style="margin-top: 15px;">

    <div class="layui-form-item" style="width: 80%;display: none">
            <input type="text" name="userid" id="userid" lay-verify="required"/>
            <input type="text" name="goodsid" id="goodsid" lay-verify="required"/>
            <input type="text" name="supplierid" id="supplierid" lay-verify="required"/>
            <input type="text" name="score" id="score" value="0" lay-verify="required"/>
    </div>

    <div class="layui-form-item" style="width: 80%;">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea name="content" id="content" lay-verify="required" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item" style="width: 80%;">
        <label class="layui-form-label">评分</label>
        <div class="layui-input-block">
            <div id="test2"></div>
        </div>
    </div>

    <div class="layui-form-item" style="width: 80%; text-align: center;">
        <button class="layui-btn" lay-submit lay-filter="formDemo">评价</button>
    </div>

</div>
<script type="text/javascript">
    layui.use(['laydate', 'form', 'upload','rate'], function () {
        var laydate = layui.laydate,
            form = layui.form,
            upload = layui.upload,
            $ = layui.jquery;
        var rate = layui.rate;

        //显示文字
        rate.render({
            elem: '#test2'
            ,value: 0 //初始值
            ,text: true //开启文本
            ,choose: function(value){
                $("#score").val(value);
            }
        });

        form.on('submit(formDemo)', function (data) {
            $.post("../evaluation/add", data.field, function (res) {
                if (res.code === 200) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000
                    }, function () {
                        var index = parent.layer.getFrameIndex(window
                            .name); //获取当前窗口的name
                        parent.layer.close(index); //关闭窗口
                    });
                } else {
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 2000
                    });
                }
            })
        });
    })
</script>
</body>
</html>
